import '../../../bean/UserTaskWrite.dart';

class TaskDetailState {
  late int currentPage;

  late List<ErrorInfo> errorInfoList;

  late String questionId; // 问卷id
  late String status; // 任务状态 1进行中 2截止 3已完成
  late String taskName; // 任务名称
  late String title; // 所属项目 问卷名称
  late String taskDesc; // 任务说明
  late String endTime; // 截止时间

  late String updateTime; // 最后统计时间
  late int collectCount; // 总问卷
  late int writeCount; // 有效问卷
  late int validCount; // 无效问卷

  // late double percent; // 任务进度 有效问卷/总问卷

  late bool isPosition; // 定位权限
  late bool isRecord; // 录音
  late bool isSignature; // 电子签名
  late bool isVideo; // 拍照留证
  late bool isLimit; // 不限制作答次数  true不限制 false限制

  late bool isShowBottom; // 是否显示底部add按钮

  UserTaskWrite? taskWrite; // 异常样本

  TaskDetailState() {
    currentPage = 1;

    questionId = '';
    status = '';
    taskName = "";
    title = "";
    taskDesc = "";
    endTime = '';

    updateTime = '';
    collectCount = 1;
    writeCount = 0;
    validCount = 0;

    // percent = 0.0;

    isPosition = true;
    isRecord = true;
    isSignature = true;
    isVideo = true;
    isLimit = false;

    isShowBottom = false;
  }
}

class ErrorInfo {
  ErrorInfo({
    this.name,
    this.title,
    this.state,
  });

  ErrorInfo.fromJson(dynamic json) {
    name = json['name'];
    title = json['title'];
    state = json['state'];
  }

  String? name;
  String? title;
  String? state;

  ErrorInfo copyWith({
    String? name,
    String? title,
    String? state,
  }) =>
      ErrorInfo(
        name: name ?? this.name,
        title: title ?? this.title,
        state: state ?? this.state,
      );

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['name'] = name;
    map['title'] = title;
    map['state'] = state;
    return map;
  }
}
